<?php 
require('./config.php');
$sql = "SELECT * FROM {$tabPre}gather_url ORDER BY id DESC";
$res = mysql_query($sql);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>gatherV1.0</title>
	<link rel="stylesheet" type="text/css" href="./Public/style.css" /> 
	<script>
		function sureDelete(id){
			if(confirm('您确定要删除该规则吗? ')){
				window.location='action.php?action=deleteRule&id='+id;
			}
		}
	</script>
</head>
<body>
	<div class="divHeader">
		<div ><a href="addRule.php">新增规则</a> || <a href="import.php">导入规则</a></div>
	</div>
	<form action="action.php" method="post">
		<table class="baseTable">
			<tr>
				<th>规则Id</th>
				<th>网站名称</th>
				<th>网址类型</th>
				<th>采集始止页</th>
				<th>规则操作</th>
				<th>采集</th>
			</tr>
			<?php 
				while($r = mysql_fetch_array($res)){
					$gatherUrlType = '连续的';
					$doMain = '';
					if($r['gatherUrlType']==0){
						$gatherUrlType = '连续的';
						$doMain = getDomain($r['gatherUrl']);
						$totalPage = $r['endPage']-$r['startPage']+1;
						$totalPage .= "<font color=black>({$r['startPage']} - {$r['endPage']})</font>";
					}else{
						$gatherUrlType = '<font color=red>指定的</font>';
						$tempUrlArray = explode("\r\n",$r['gatherUrlSets']);
						$doMain = getDomain($tempUrlArray[0]); 
						$totalPage = sizeof($tempUrlArray);
					}
			?>
			<tr>
				<td><?php echo $r['id'];?></td>
				<td><?php echo $r['gatherWebName'];?> [<a href="<?php echo getDomain($r['gatherUrl']);?>" target='_blank'><?php echo $doMain;?></a>]</td>
				<td><?php echo $gatherUrlType;?></td>
				<td>共<font color=red><?php echo $totalPage; ?></font>页</td>
				<td align="center"><a href="modifyRule.php?id=<?php echo $r['id'];?>">修改</a> || <a href="modifyRule.php?id=<?php echo $r['id'];?>&copy=copy">复制</a> || <a href="action.php?action=export&id=<?php echo $r['id'];?>">导出</a> || <a href="#" onclick="sureDelete(<?php echo $r['id'];?>)">删除</a></td>
				
				<td align="center"><a target="_blank" href="action.php?action=gather&id=<?php echo $r['id'];?>">采集</a> || <a target="_blank" href="action.php?action=gather&id=<?php echo $r['id'];?>&test=test">测试</a> || <a title="清空采集记录" href="action.php?action=clearLog&id=<?php echo $r['id'];?>&test=test">清空记录</a></td>
			</tr>
			<?php 
				}
			?>
		</table>
	</form>
</body>
</html>